<template>
	<view>
		<view class="search">
			<view class="search-left">
				<u-search height="70rpx" @change="change" bgColor="#fff" :showAction="false" placeholder="请搜索手机号或者用户名"
					v-model="wd"></u-search>
			</view>
			<view class="search-right" @tap="scans">
				<u-icon name="scan" color="#669bf9" size="24"></u-icon>
			</view>
		</view>
		<!-- 		<view class="nav">
			<u-subsection style="height: 70rpx;" @change="sectionChange" :list="navlist"
				:current="current"></u-subsection>
		</view> -->
		<view class="product" v-if="List != []">
			<view class="List" v-for="(item,i) in List" :key="i" @tap="godetails(item)">
				<view class="p-header">
					<view class="p-name">
						<text v-if="type == 1">重量：{{ item.product }}Kg</text>
					</view>
					<view class="p-status">
						<text v-if="item.status == 'kx'">空闲</text>
						<text v-if="item.status == 'zz'">在租</text>
					</view>
				</view>
				<view class="p-content" v-if="st == 1">
					<view class="p-left">
						客户姓名
					</view>
					<view class="p-right">
						{{ item.kename }}
					</view>
				</view>
				<view class="p-content" v-if="st == 1">
					<view class="p-left">
						客户电话
					</view>
					<view class="p-right">
						{{ item.ketel }}
					</view>
				</view>

				<view class="p-content">
					<view class="p-left">
						租借日期
					</view>
					<view class="p-right">
						{{ item.zuri }}
					</view>
				</view>
				<view class="p-content">
					<view class="p-left">
						归还日期
					</view>
					<view class="p-right">
						在租
					</view>
				</view>
				<view class="p-content">
					<view class="p-left">
						租借押金
					</view>
					<view class="p-right">
						{{ item.yajin }}元
					</view>
				</view>

				<view class="p-content">
					<view class="p-left">
						标准租金
					</view>
					<view class="p-right">
						<text>{{ item.rimoney }}元/30天</text>
					</view>
				</view>

				<view class="p-content" v-if="type == 0">
					<view class="p-left">
						租金
					</view>
					<view class="p-right">
						<text>{{ item.zujin }}元</text>
					</view>
				</view>
				<view class="p-content">
					<view class="p-left">
						收费
					</view>
					<view class="p-right">
						<text>{{ item.price }}元</text>
					</view>
				</view>
				<view class="p-content" v-if="st == 1">
					<view class="p-left">
						客户地址
					</view>
					<view class="p-right">
						{{ item.keadress }}
					</view>
				</view>
				<view class="p-contents">
					<view class="p-top">
						备注
					</view>
					<view class="p-bottom">
						<view class="" v-if="item.remark">
							{{ item.remark }}
						</view>
						<view class="" v-else>
							暂无
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				wd: '',
				page: 1,
				List: [],
				navlist: ['已租商品', '未租商品', ],
				type: 1,
				current: 0,
				st:0
			}
		},
		onShow() {
			this.getlist()
			this.st = uni.getStorageSync('st')
		},
		onReachBottom() {
			this.page++
			this.getlist()
		},
		onPullDownRefresh() {
			this.page = 1
			this.getlist()
			uni.stopPullDownRefresh()
		},
		methods: {
			scans() {
				uni.scanCode({
					success: (res) => {
						let id = res.result
						uni.navigateTo({
							url: '/pages/index/details?id=' + id + "&type=" + 1
						})
					},
					fail: (err) => {
						uni.showToast({
							title: '扫码失败',
							icon: 'none'
						})
					}
				})
			},
			change(e) {
				this.page = 1
				this.getlist()
			},
			getlist() {
				uni.showLoading({
					title: '正在加载'
				})
				this.$http.Post('cper/chanList', {
					wd: this.wd,
					page: this.page,
					type: this.type
				}, (result) => {
					uni.hideLoading()
					if (this.page == 1) {
						this.List = []
					}
					this.List = this.List.concat(result.data.data)
				})
			},
			godetails(item) {
				let id = ''
				if (this.type == 0) {
					id = item.id
				} else {
					id = item.zguanzi_id
				}
				uni.navigateTo({
					url: '/pages/index/details?id=' + id + "&type=" + 0
				})
			},
			sectionChange(e) {
				this.current = e
				console.log(e)
				if (e == 0) { //已租
					this.type = 1
				} else { //未租
					this.type = 0
				}
				this.page = 1
				this.getlist()
			}
		}
	}
</script>

<style>
	.search {
		margin: 20rpx auto 0 auto;
		width: 90%;
		height: 100rpx;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.search-left {
		width: 92%;
		display: flex;
	}

	.search-right {
		width: 8%;
		display: flex;
		justify-content: flex-end;
		align-items: center;
		position: relative;
		left: 10rpx;
	}

	.nav {
		width: 80%;
		height: 100rpx;
		margin: 0rpx auto 0 auto;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.List {
		margin: 20rpx auto;
		width: 94%;
		border-radius: 16rpx;
		background-color: #fff;
		padding-bottom: 20rpx;
	}

	.p-header {
		display: flex;
		align-items: center;
		justify-content: space-between;
		width: 94%;
		margin: 0 auto;
		height: 90rpx;
		border-bottom: 1rpx solid #f4f4f4;
	}

	.p-name {
		font-weight: bold;
	}

	.p-status {
		border-radius: 8rpx;
		font-size: 28rpx;
		padding: 5rpx 12rpx;
		background-color: #f0f5fc;
		color: #669bf9;
	}

	.p-content {
		width: 94%;
		margin: 20rpx auto;
		display: flex;
		align-items: center;
		color: #7a7a7a;
		font-size: 30rpx;
	}

	.p-left {
		width: 25%;
		height: 100%;
		display: flex;
		align-items: center;
		font-weight: bold;

	}

	.p-right {
		width: 75%;
		height: 100%;
		display: flex;
		align-items: center;
		justify-content: flex-end;
		text-align: right;
	}

	.p-contents {
		width: 94%;
		margin: 20rpx auto;
		color: #7a7a7a;
		font-size: 30rpx;
	}

	.p-top {
		width: 100%;
		height: 100%;
		display: flex;
		align-items: center;
		font-weight: bold;
	}

	.p-bottom {
		padding-top: 15rpx;
	}


	textarea {
		width: 100%;
		height: auto;
		word-wrap: break-word;

	}
</style>